#pragma once
#include "common.h"

class CentralCache
{
public:
//获取CentralCache单例对象的指针
    static CentralCache* GetInstance()
    {
        return &_sInst;
    }
    //获取空的span
    Span* GetOneSpan(SpanList& List,size_t size);

    //从中心缓存获取一段内存给threadCache
    //bachNum获取多少个对象
    size_t FetchRangeObj(void*& start,void*& end,size_t bachNum,size_t size);

    //threadCache还内存回来
    void ObjGiveBack(size_t size,void* start);

private:
//饿汉模式
    CentralCache()
    {}
    CentralCache(const CentralCache& obj) = delete;
    //带头双向循环链表
    //多线程桶锁
    SpanList _spanLists[NFREELIST];
    static CentralCache _sInst;
};